// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

LL n;

int check(LL n) {
    int ans = 0;
    for (int i=2; i<=n; ++i) {
        LL tn = n;
        while (tn % i == 0)
            tn /= i;
        ans += (tn % i == 1);
    }
    return ans;
}

vector<LL> dfac(LL n) {
    vector<LL> res;
    for (LL i=2; i*i<=n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            if (i*i!=n)
                res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
LL solve(LL n) {
    if (n == 2)
        return 1;
    auto d1 = dfac(n), d2 = dfac(n-1);
    int ans = sz(d2)+1;
    for (LL x : d1) {

        LL tn = n;
        while (tn % x == 0)
            tn /= x;
        ans += tn % x == 1;
    }
    return ans+1;
}
int main(int argc, char const *argv[]) {
    // code
    // dbg(check(6), check(3141));
    // for (int i=1000; i<=2000; ++i)
    //     if (solve(i) != check(i)) {
    //         dbg(i);
    //         return 0;
    //     }
    LL n;
    cin >> n;
    cout << solve(n) << endl;
    // if (n == 2) {
    //     puts("1");
    // }
    return 0;
}
